; void agregarAd(lista* l, int n);

extern malloc

global agregarAd

%define ptr_l [ebp + 8]
%define n [ebp + 12]
%define off_dato 0
%define off_prox 4

section .text

agregarAd:
	push ebp
	mov ebp, esp
	push esi
	push edi
	push ebx
	
	push dword 8
	call malloc
	add esp, 4
	cmp eax, 0
	je fin
	
	mov edx, n
	mov [eax + off_dato], edx
	
	mov esi, ptr_l
	mov edi, [esi]
	
	mov [esi], eax
	mov [eax + off_prox], edi
	
fin:
	pop ebx
	pop edi
	pop esi
	pop ebp
	ret
